package controllers

import (
	"disease/models"
	beego "github.com/beego/beego/v2/server/web"
)

type DiseaseController struct {
	beego.Controller
}
type JsonRes struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

func (c *DiseaseController) List() {
	var disease []models.Disease
	err := models.DB.Debug().Find(&disease).Error
	if err != nil {
		c.Data["json"] = JsonRes{
			Code: 500,
			Msg:  "查询失败",
			Data: nil,
		}
		c.ServeJSON()
	} else {
		c.Data["json"] = JsonRes{
			Code: 200,
			Msg:  "查询成功",
			Data: disease,
		}
		c.ServeJSON()
	}
}
